﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TPCN.DAL
{
    public class ShoppingCartItem
    {
        private string _HangID;

        public string HangID
        {
            get { return _HangID; }
            set { _HangID = value; }
        }
        private string _Tenhang;

        public string Tenhang
        {
            get { return _Tenhang; }
            set { _Tenhang = value; }
        }
        private double _Dongia;

        public double Dongia
        {
            get { return _Dongia; }
            set { _Dongia = value; }
        }
        private int _Soluong;

        public int Soluong
        {
            get { return _Soluong; }
            set { _Soluong = value; }
        }
        private double _Thanhtien;

        public double Thanhtien
        {
            get { return _Soluong * _Dongia; }
            set { _Thanhtien = _Soluong *_Dongia; }
        }

        public bool Equals(ShoppingCartItem item)
        {
            return this.HangID == item.HangID;
        }

        public bool Equals(string HangID)
        {
            return this.HangID == HangID;
        }

        public ShoppingCartItem(string HangID)
        {
            HangObj obj = HangDAL.GetByID(HangID);
            this.HangID = HangID;
            this.Tenhang = obj.Tenhang;
            this.Soluong = 1;
            this.Dongia = Convert.ToDouble(obj.Giabanle);
        }

        public ShoppingCartItem()
        {
            this.Soluong = 1;
            this.Dongia = 0;
        }
    }
}
